<?php
namespace Modules\Admin\Http\Controllers;
use Illuminate\Http\Request;
use Modules\Admin\Http\Requests\CommonStatusRequest;
use Modules\Admin\Models\Image as ImageModel;
use Modules\Admin\Http\Controllers\CommonController;
class ImageController extends CommonController
{
	/**
	 * @name  列表
	 */
    public function index()
    { 
		$status = ImageModel::common_status();
		$image_type = (new ImageModel())->image_type();
        return view('admin::image.index',compact('image_type','status'));
    }
	/**
	 * @name  列表数据
	 */
    public function data(Request $request)
    {
	    $model = ImageModel::query();
		$params = $request->all();
		$model = query_condition($model,$params);
		if (isset($params['open']) && $params['open'] != ''){
            $model = $model->where('open',$params['open']);
        }
        $res = $model->orderBy('id','desc')->paginate($params['limit'])->toArray(); 
		$res['data'] = (new ImageModel())->image_list($res['data']);	
        return response()->json(['code' => 0, 'msg'   => config('admin.limit_msg'),'count' => $res['total'],'data'  => $res['data'],'rel'=>1]);
    }
	/**
	 * @name  调整菜单状态数据处理
	 */
    public function status(CommonStatusRequest $request,$id)
    {
		return (new ImageModel())->common_status_update($request->all(),$id,route('admin.image.index'));  
    }
	/**
	 * @name  批量删除数据处理
	 */
    public function destroy_all(Request $request)
    {
		return (new ImageModel())->image_destroy();   
    }
	
	
	
	
	
}
